




#include "..\headers\BC_Game.h"



BCGame::BCGame(int screenWidth, int screenHeight, int screenDepth, bool fullscreen):
	BCCore(screenWidth,screenHeight,screenDepth,fullscreen),
		mainTexture(NULL),
		dummy(NULL)
	{

		BCEntity::init(device,mainTexture);
		player1 = new BCPlayer(BCVector2d(100,100),0.8f,1.0f,0.001f,1.0f);
	}


	BCGame::~BCGame()
	{
		mainTexture->Release();
		delete player1;
	}


void BCGame::drawAll()
{

	device->Clear( 0, NULL, D3DCLEAR_TARGET,
                     D3DCOLOR_COLORVALUE(0,0,0,1.0f), 1.0f, 0 );
	
	device->BeginScene();

	player1->update(1.0f);
	player1->draw();
	
	device->EndScene();
	device->Present( NULL, NULL, NULL, NULL );

}




bool BCGame::isGameRunning()
{
	MSG uMsg;
	ZeroMemory(&uMsg,sizeof(MSG));

	if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
    { 
        TranslateMessage( &uMsg );
        DispatchMessage( &uMsg );
    }
   
	return !windowClosing;
}




void BCGame::loadTexture(const std::string& path)
{
	if (mainTexture)
	{
		if (mainTexture->Release() > 0) 
		{
			BC_DEBUG_ERROR("Texture could not be released properly... a memory leak occured")
		}
		mainTexture = NULL;
	}

	if (!SUCCEEDED(D3DXCreateTextureFromFile(device,path.c_str(),&mainTexture))) 
	{
		BC_DEBUG_ERROR("Could not load main texture !");
	}

	BCEntity::init(device,mainTexture);

}




